home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 5
/
005.d81
/
sound designer
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
26KB
|
800 lines
10 rem sound generator
12 print"[147][144]":poke53280,4:poke53281,1
13 gosub51000
15 dimoo$(1):oo$(0)="off":oo$(1)="on"
20 dima%(2),d%(2),s%(2),r%(2),ad%(2),sr%(2),p1%(2),p2%(2)
30 dimt1%(2),t2%(2),wf%(2),pw%(2)
50 forl=54272to54296:pokel,0:next
55 forv=0to2
57 tr%(v)=0:st%(v)=0:pu%(v)=1:no%(v)=0:rm%(v)=0:sy%(v)=0:te%(v)=0
60 a%(v)=8:d%(v)=8:s%(v)=8:r%(v)=8:ad%(v)=136:sr%(v)=136
70 p1%(v)=8:p2%(v)=0:t1%(v)=32:t2%(v)=128
75 wf%(v)=64:pw%(v)=256*p1%(v)+p2%(v)
85 poke54277+7*v,ad%(v):poke54278+7*v,sr%(v):poke54276+7*v,wf%(v)
90 poke54275+7*v,p1%(v):poke54274+7*v,p2%(v):poke54273+7*v,t1%(v)
92 poke54272+7*v,t2%(v):next
95 v%=15:vn%=0:poke54296,v%
97 cf%=0:re%=0:f1%=0:f2%=0:f3%=0:lp%=0:bp%=0:hp%=0:o3%=0:ef%=0
100 rem start
110 m%=1
115 ht=8
117 pi%=16
120 print"[147][144]":poke53280,4:poke53281,1
125 print"[156][157][157][157][157][157][157][157][157][157][157][157][157][198]=[198]ilter[157][157][157][157][157][157][157][157][205]=[205]isc.[157][157][157][157][157][157][157][210][197][212][213][210][206]=[197]xit";
127 print"[157][157][157][157][157][157][157][157][157][157][157]?=[201]nfo[144]"
130 printtab(ht-2)"[195]-64 [211]ound [199]enerator[144]"
140 print:printtab(ht)"[195]oarse [212]une:"t1%(vn%)
150 print:printtab(ht)"[198]ine [212]une:"t2%(vn%)
160 print:printtab(ht)"[193]ttack:"a%(vn%)
170 print:printtab(ht)"[196]ecay:"d%(vn%)
180 print:printtab(ht)"[211]ustain:"s%(vn%)
190 print:printtab(ht)"[210]elease:"r%(vn%)
200 print:printtab(ht)"[215]aveform:"2*int(wf%(vn%)/2)
210 print:printtab(ht)"[208]ulse [215]idth:"pw%(vn%)
220 print:printtab(ht)"[214]olume:"v%
230 print:printtab(ht+3)"[211]ound ";:ifwf%(vn%)/2=int(wf%(vn%)/2)thenprint"off"
232 ifwf%(vn%)/2<>int(wf%(vn%)/2)thenprint"on"
235 print:printtab(ht)"[214]oice:"vn%+1"[144]"
240 gosub5000
250 gosub1000
255 ifrd=1then120
260 geti$
265 ifval(i$)>0andval(i$)<4thenvn%=val(i$)-1:goto120
266 ifi$="[198]"ori$="f"thengosub30000:goto120
267 ifi$=chr$(13)then500
268 ifi$="[205]"ori$="m"thengosub36000:goto120
269 ifi$="?"ori$="/"thengosub40000:goto120
270 ifi$<>""thengosub1500
300 goto250
350 a$=mid$(str$(a),2):return
360 nl=0:print"[200]it any key to continue."
370 geti$:ifi$=""then370
380 print"[147]":return
400 printleft$("",v)spc(h-1):return
450 rem print program line
452 ifpr=0thennl=nl+1:ifnl>10thengosub360
455 a=ln:gosub350:print#1,a$" ";
457 ifl1<0then480
460 print#1,"poke";:a=l1:gosub350:print#1,a$",";
465 a=v1:gosub350:print#1,a$":";
470 ifl2>=0thena=l2:gosub350:print#1,"poke"a$",";:a=v2:gosub350:print#1,a$":";
480 print#1,"rem "r$:ln=ln+li:return
500 rem end
505 print"[147]":input"[209]uit now";i$:ifleft$(i$,1)<>"[217]"andleft$(i$,1)<>"y"then120
510 forl=54272to54296:pokel,0:next
520 print:input"[211]ee pokes to make sound";i$
530 ifleft$(i$,1)="[206]"orleft$(i$,1)="n"then900
532 print:print"[207]utput to ([211])creen, ([208])rinter, or":input"([212])ext file";i$:i$=left$(i$,1)
533 pr=-1:ifi$="[208]"ori$="p"thenpr=1
534 ifi$="[212]"ori$="t"thenpr=2:gosub1900
535 ifi$="[211]"ori$="s"thenpr=0
536 ifpr=-1then532
537 ifpr=1thenopen1,4,7
538 ifpr=0thenopen1,3,7
539 print"[147]"
555 nl=0
560 print#1,"10 rem clear sound chip"
570 print#1,"20 forl=54272to54296:pokel,0:next"
580 print#1,"30 rem set up registers for sound"
585 ln=40:li=10
590 l1=54296:v1=v%+16*lp%+32*bp%+64*hp%+128*o3%:r$="mode/vol":l2=-1:gosub450
610 iff1%+f2%+f3%+ef%>0thengosub800
615 a=0:forv=0to2:ifwf%(v)/2<>int(wf%(v)/2)thena=1
617 next:ifa=0thenwf%(0)=wf%(0)+1
620 forv=0to2
622 a=v+1:ifa>2thena=0
625 if(wf%(v)/2=int(wf%(v)/2))andnot((rm%(a)=1)or(sy%(a)=1))then680
630 l1=-1:r$="voice"+str$(v+1):gosub450
640 l1=54273+7*v:v1=t1%(v):l2=54272+7*v:v2=t2%(v):r$="pitch":gosub450
650 l1=54277+7*v:v1=ad%(v):l2=54278+7*v:v2=sr%(v):r$="adsr":gosub450
660 l1=54276+7*v:v1=2*int(wf%(v)/2):l2=-1:r$="waveform":gosub450
670 ifpu%(v)thenl1=54275+7*v:v1=p1%(v):l2=54274+7*v:v2=p2%(v)
675 ifpu%(v)thenr$="pw":gosub450
680 next
690 l1=-1:r$="now start the tone!":gosub450
695 print#1,mid$(str$(ln),2)" ";
700 forv=0to2
710 ifwf%(v)/2<>int(wf%(v)/2)thena=54276+7*v:gosub350:print#1,"poke"a$",";
715 ifwf%(v)/2<>int(wf%(v)/2)thena=wf%(v):gosub350:print#1,a$":";
720 next:print#1,"rem start":ln=ln+li
730 print#1,mid$(str$(ln),2)" fora=1to800:next:rem length of tone":ln=ln+li
745 print#1,mid$(str$(ln),2)" ";
750 forv=0to2
760 ifwf%(v)/2<>int(wf%(v)/2)thena=54276+7*v:gosub350:print#1,"poke"a$",";
765 ifwf%(v)/2<>int(wf%(v)/2)thena=wf%(v)-1:gosub350:print#1,a$":";
770 next:print#1,"rem stop":ln=ln+li
772 ifpr<>2thenprint#1
775 close1
777 ifpr=2thenclose15
780 print"[200]it any key to continue."
790 geti$:ifi$=""then790
795 goto900
800 rem filter
810 l1=54295:v1=f1%+f2%*2+f3%*4+ef%*8+re%*16:l2=-1:r$="filter":gosub450
815 a=int(cf%/8):b=cf%-8*a
820 l1=54294:v1=a:l2=54293:v2=b:r$="cutoff frequency":gosub450
830 return
900 print"[147]":i$="y":input"[212]ry another sound";i$
910 ifleft$(i$,1)<>"[206]"andleft$(i$,1)<>"n"thenrun
920 print"[194]ye.":goto63000:this is for the end
1000 rem read joystick
1005 rd=0
1010 jv=peek(56320)
1020 fr=jvand16
1030 jv=15-(jvand15)
1040 if(jvand1)ori$="[145]"thengosub2000
1050 if(jvand2)ori$=""thengosub3000
1060 if(jvand4)ori$="[157]"thengosub1200
1070 if(jvand8)ori$=""thengosub1300
1080 iffr=0andbk=0thenbk=1:gosub4000
1090 iffr<>0thenbk=0
1100 return
1200 onm%gosub10000,12000,14000,16000,18000,20000,22000,24000,26000:return
1300 onm%gosub11000,13000,15000,17000,19000,21000,22000,25000,27000:return
1500 rem keyboard
1502 ifi$="0"thenh=ht+4:v=22:gosub400:print"[211]ound off"
1505 ifi$="0"thenforv=0to2:wf%(v)=2*int(wf%(v)/2):poke54276+7*v,wf%(v):next:return
1507 ifi$=" "thengosub4000
1515 ifi$<"[133]"ori$>"[140]"thenreturn
1520 ifi$="[133]"thenpi%=1
1530 ifi$="[137]"thenpi%=2
1540 ifi$="[134]"thenpi%=4
1550 ifi$="[138]"thenpi%=8
1560 ifi$="[135]"thenpi%=16
1570 ifi$="[139]"thenpi%=32
1580 ifi$="[136]"thenpi%=64
1590 ifi$="[140]"thenpi%=128
1600 return
1900 rem open textfile
1910 print:f$="":input"[198]ilename";f$
1920 iff$=""then1910
1930 open15,8,15,"s0:"+f$
1940 open1,8,1,f$+",s,w"
1950 return
2000 rem move up
2010 gosub5500
2020 m%=m%-1:ifm%=0thenm%=9
2030 gosub5000
2040 return
3000 rem move down
3010 gosub5500
3020 m%=m%+1:ifm%=10thenm%=1
3030 gosub5000
3040 return
4000 rem on/off
4010 ifwf%(vn%)/2=int(wf%(vn%)/2)then4100
4020 wf%(vn%)=wf%(vn%)-1:h=ht+4:v=22:gosub400:print"[211]ound off":goto4030
4030 poke54276+7*vn%,wf%(vn%)
4040 return
4100 wf%(vn%)=wf%(vn%)+1:h=ht+4:v=22:gosub400:print"[211]ound on ":goto4030
5000 rem plot 'cursor'
5010 v=2*m%+2:h=ht-1:gosub400:print">[144]":return
5500 rem unplot 'cursor'
5510 v=2*m%+2:h=ht-1:gosub400:print" ":return
10000 rem lower coarse tune
10010 t1%(vn%)=t1%(vn%)-1:ift1%(vn%)<0thent1%(vn%)=255
10020 poke54273+7*vn%,t1%(vn%)
10040 v=4:h=ht+13:gosub400:printt1%(vn%)"[157] "
10050 return
11000 rem raise coarse tune
11010 t1%(vn%)=t1%(vn%)+1:ift1%(vn%)>255thent1%(vn%)=0
11020 poke54273+7*vn%,t1%(vn%)
11030 v=4:h=ht+13:gosub400:printt1%(vn%)"[157] "
11040 return
12000 rem lower fine tune
12010 t2%(vn%)=t2%(vn%)-1:ift2%(vn%)<0thent2%(vn%)=255
12020 poke54272+7*vn%,t2%(vn%)
12030 v=6:h=ht+11:gosub400:printt2%(vn%)"[157] "
12040 return
13000 rem raise fine tune
13010 t2%(vn%)=t2%(vn%)+1:ift2%(vn%)>255thent2%(vn%)=0
13020 poke54272+7*vn%,t2%(vn%)
13030 v=6:h=ht+11:gosub400:printt2%(vn%)"[157] "
13040 return
14000 rem lower attack
14010 a%(vn%)=a%(vn%)-1:ifa%(vn%)<0thena%(vn%)=15
14020 ad%(vn%)=16*a%(vn%)+d%(vn%):poke54277+7*vn%,ad%(vn%)
14030 v=8:h=ht+8:gosub400:printa%(vn%)"[157] "
14040 return
15000 rem raise attack
15010 a%(vn%)=a%(vn%)+1:ifa%(vn%)>15thena%(vn%)=0
15020 ad%(vn%)=16*a%(vn%)+d%(vn%):poke54277+7*vn%,ad%(vn%)
15030 v=8:h=ht+8:gosub400:printa%(vn%)"[157] "
15040 return
16000 rem lower decay
16010 d%(vn%)=d%(vn%)-1:ifd%(vn%)<0thend%(vn%)=15
16020 ad%(vn%)=16*a%(vn%)+d%(vn%):poke54277+7*vn%,ad%(vn%)
16030 v=10:h=ht+7:gosub400:printd%(vn%)"[157] "
16040 return
17000 rem raise decay
17010 d%(vn%)=d%(vn%)+1:ifd%(vn%)>15thend%(vn%)=0
17020 ad%(vn%)=16*a%(vn%)+d%(vn%):poke54277+7*vn%,ad%(vn%)
17030 v=10:h=ht+7:gosub400:printd%(vn%)"[157] "
17040 return
18000 rem lower sustain
18010 s%(vn%)=s%(vn%)-1:ifs%(vn%)<0thens%(vn%